package com.shandao.shangxiu.ui;

import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.ProgressBar;

import com.shandao.shangxiu.R;
import com.shandao.shangxiu.base.BaseActivity;


/**
 * 显示网页时页面
 * @author king
 */
public class MyWebViewActivity extends BaseActivity {

    private WebView vbBusiness;
    private ProgressBar bar;
    

    @Override
    protected int getLayoutId() {
        return R.layout.activity_my_webview;
    }


    @Override
    public void initView() {
        vbBusiness= (WebView) findViewById(R.id.web);
        bar = (ProgressBar)findViewById(R.id.myProgressBar);
        //设置WebView属性，能够执行Javascript脚本
        vbBusiness.getSettings().setJavaScriptEnabled(true);
    }

    @Override
    public void initData() {
        Bundle bundle = getIntent().getExtras();
        String title = bundle.getString("title");
        setToolbarTitle("webview");
        String URL = getIntent().getExtras().getString("url");
        //WebView加载web资源
        vbBusiness.setWebChromeClient(new WebChromeClient() {  
                   public void onProgressChanged(WebView view, int progress) {  
                	   if (progress == 100) {
                           bar.setVisibility(View.GONE);
                       } else {
                           bar.setProgress(progress);
                       }
                       super.onProgressChanged(view, progress);
            }  
         });  
        vbBusiness.loadUrl(URL);
    }

    @Override
    public void onClick(View v) {

    }
}
